home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / fileutil / fileutils-3.16.tar.gz / fileutils-3.16.tar / fileutils-3.16 / lib / posixtm.c < prev    next >
C/C++ Source or Header  |  1996-11-02  |  26KB  |  1,047 lines

  1.  
  2. /*  A Bison parser, made from posixtm.y
  3.  by  GNU Bison version 1.25
  4.   */
  5.  
  6. #define YYBISON 1  /* Identify Bison output.  */
  7.  
  8. #define    DIGIT    258
  9.  
  10. #line 19 "posixtm.y"
  11.  
  12.  
  13. #ifdef HAVE_CONFIG_H
  14. #include <config.h>
  15. #endif
  16.  
  17. /* The following block of alloca-related preprocessor directives is here
  18.    solely to allow compilation by non GNU-C compilers of the C parser
  19.    produced from this file by old versions of bison.  Newer versions of
  20.    bison include a block similar to this one in bison.simple.  */
  21.  
  22. #ifdef __GNUC__
  23. #define alloca __builtin_alloca
  24. #else
  25. #ifdef HAVE_ALLOCA_H
  26. #include <alloca.h>
  27. #else
  28. #ifdef _AIX
  29.  #pragma alloca
  30. #else
  31. void *alloca ();
  32. #endif
  33. #endif
  34. #endif
  35.  
  36. #include <stdio.h>
  37. #include <sys/types.h>
  38.  
  39. #ifdef TM_IN_SYS_TIME
  40. #include <sys/time.h>
  41. #else
  42. #include <time.h>
  43. #endif
  44.  
  45. /* Some old versions of bison generate parsers that use bcopy.
  46.    That loses on systems that don't provide the function, so we have
  47.    to redefine it here.  */
  48. #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
  49. #define bcopy(from, to, len) memcpy ((to), (from), (len))
  50. #endif
  51.  
  52. #define YYDEBUG 1
  53.  
  54. /* Lexical analyzer's current scan position in the input string. */
  55. static char *curpos;
  56.  
  57. /* The return value. */
  58. static struct tm t;
  59.  
  60. time_t mktime ();
  61.  
  62. /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
  63.    as well as gratuitiously global symbol names, so we can have multiple
  64.    yacc generated parsers in the same program.  Note that these are only
  65.    the variables produced by yacc.  If other parser generators (bison,
  66.    byacc, etc) produce additional global names that conflict at link time,
  67.    then those parser generators need to be fixed instead of adding those
  68.    names to this list. */
  69.  
  70. #define yymaxdepth pt_maxdepth
  71. #define yyparse pt_parse
  72. #define yylex   pt_lex
  73. #define yyerror pt_error
  74. #define yylval  pt_lval
  75. #define yychar  pt_char
  76. #define yydebug pt_debug
  77. #define yypact  pt_pact
  78. #define yyr1    pt_r1
  79. #define yyr2    pt_r2
  80. #define yydef   pt_def
  81. #define yychk   pt_chk
  82. #define yypgo   pt_pgo
  83. #define yyact   pt_act
  84. #define yyexca  pt_exca
  85. #define yyerrflag pt_errflag
  86. #define yynerrs pt_nerrs
  87. #define yyps    pt_ps
  88. #define yypv    pt_pv
  89. #define yys     pt_s
  90. #define yy_yys  pt_yys
  91. #define yystate pt_state
  92. #define yytmp   pt_tmp
  93. #define yyv     pt_v
  94. #define yy_yyv  pt_yyv
  95. #define yyval   pt_val
  96. #define yylloc  pt_lloc
  97. #define yyreds  pt_reds          /* With YYDEBUG defined */
  98. #define yytoks  pt_toks          /* With YYDEBUG defined */
  99. #define yylhs   pt_yylhs
  100. #define yylen   pt_yylen
  101. #define yydefred pt_yydefred
  102. #define yydgoto pt_yydgoto
  103. #define yysindex pt_yysindex
  104. #define yyrindex pt_yyrindex
  105. #define yygindex pt_yygindex
  106. #define yytable  pt_yytable
  107. #define yycheck  pt_yycheck
  108.  
  109. static int yylex ();
  110. static int yyerror ();
  111.  
  112. #ifndef YYSTYPE
  113. #define YYSTYPE int
  114. #endif
  115. #include <stdio.h>
  116.  
  117. #ifndef __cplusplus
  118. #ifndef __STDC__
  119. #define const
  120. #endif
  121. #endif
  122.  
  123.  
  124.  
  125. #define    YYFINAL        15
  126. #define    YYFLAG        -32768
  127. #define    YYNTBASE    5
  128.  
  129. #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? yytranslate[x] : 9)
  130.  
  131. static const char yytranslate[] = {     0,
  132.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  133.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  134.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  135.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     4,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     1,     2,     3
  158. };
  159.  
  160. #if YYDEBUG != 0
  161. static const short yyprhs[] = {     0,
  162.      0,     7,     9,    12,    13,    14,    17
  163. };
  164.  
  165. static const short yyrhs[] = {     8,
  166.      8,     8,     8,     6,     7,     0,     8,     0,     8,     8,
  167.      0,     0,     0,     4,     8,     0,     3,     3,     0
  168. };
  169.  
  170. #endif
  171.  
  172. #if YYDEBUG != 0
  173. static const short yyrline[] = { 0,
  174.    125,   154,   161,   168,   179,   182,   191
  175. };
  176. #endif
  177.  
  178.  
  179. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  180.  
  181. static const char * const yytname[] = {   "$","error","$undefined.","DIGIT",
  182. "'.'","date","year","seconds","digitpair", NULL
  183. };
  184. #endif
  185.  
  186. static const short yyr1[] = {     0,
  187.      5,     6,     6,     6,     7,     7,     8
  188. };
  189.  
  190. static const short yyr2[] = {     0,
  191.      6,     1,     2,     0,     0,     2,     2
  192. };
  193.  
  194. static const short yydefact[] = {     0,
  195.      0,     0,     7,     0,     0,     4,     5,     2,     0,     1,
  196.      3,     6,     0,     0,     0
  197. };
  198.  
  199. static const short yydefgoto[] = {    13,
  200.      7,    10,     2
  201. };
  202.  
  203. static const short yypact[] = {     2,
  204.      5,     2,-32768,     2,     2,     2,    -3,     2,     2,-32768,
  205. -32768,-32768,     9,    10,-32768
  206. };
  207.  
  208. static const short yypgoto[] = {-32768,
  209. -32768,-32768,    -2
  210. };
  211.  
  212.  
  213. #define    YYLAST        10
  214.  
  215.  
  216. static const short yytable[] = {     4,
  217.      9,     5,     6,     8,     1,    11,    12,     3,    14,    15
  218. };
  219.  
  220. static const short yycheck[] = {     2,
  221.      4,     4,     5,     6,     3,     8,     9,     3,     0,     0
  222. };
  223. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  224. #line 3 "/p/share/bison.simple"
  225.  
  226. /* Skeleton output parser for bison,
  227.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  228.  
  229.    This program is free software; you can redistribute it and/or modify
  230.    it under the terms of the GNU General Public License as published by
  231.    the Free Software Foundation; either version 2, or (at your option)
  232.    any later version.
  233.  
  234.    This program is distributed in the hope that it will be useful,
  235.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  236.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  237.    GNU General Public License for more details.
  238.  
  239.    You should have received a copy of the GNU General Public License
  240.    along with this program; if not, write to the Free Software
  241.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  242.  
  243. /* As a special exception, when this file is copied by Bison into a
  244.    Bison output file, you may use that output file without restriction.
  245.    This special exception was added by the Free Software Foundation
  246.    in version 1.24 of Bison.  */
  247.  
  248. #ifndef alloca
  249. #ifdef __GNUC__
  250. #define alloca __builtin_alloca
  251. #else /* not GNU C.  */
  252. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || defined (HAVE_ALLOCA_H)
  253. #include <alloca.h>
  254. #else /* not sparc */
  255. #if defined (MSDOS) && !defined (__TURBOC__)
  256. #include <malloc.h>
  257. #else /* not MSDOS, or __TURBOC__ */
  258. #if defined(_AIX)
  259. #include <malloc.h>
  260.  #pragma alloca
  261. #else /* not MSDOS, __TURBOC__, or _AIX */
  262. #ifdef __hpux
  263. #ifdef __cplusplus
  264. extern "C" {
  265. void *alloca (unsigned int);
  266. };
  267. #else /* not __cplusplus */
  268. void *alloca ();
  269. #endif /* not __cplusplus */
  270. #endif /* __hpux */
  271. #endif /* not _AIX */
  272. #endif /* not MSDOS, or __TURBOC__ */
  273. #endif /* not sparc.  */
  274. #endif /* not GNU C.  */
  275. #endif /* alloca not defined.  */
  276.  
  277. /* This is the parser code that is written into each bison parser
  278.   when the %semantic_parser declaration is not specified in the grammar.
  279.   It was written by Richard Stallman by simplifying the hairy parser
  280.   used when %semantic_parser is specified.  */
  281.  
  282. /* Note: there must be only one dollar sign in this file.
  283.    It is replaced by the list of actions, each action
  284.    as one case of the switch.  */
  285.  
  286. #define yyerrok        (yyerrstatus = 0)
  287. #define yyclearin    (yychar = YYEMPTY)
  288. #define YYEMPTY        -2
  289. #define YYEOF        0
  290. #define YYACCEPT    return(0)
  291. #define YYABORT     return(1)
  292. #define YYERROR        goto yyerrlab1
  293. /* Like YYERROR except do call yyerror.
  294.    This remains here temporarily to ease the
  295.    transition to the new meaning of YYERROR, for GCC.
  296.    Once GCC version 2 has supplanted version 1, this can go.  */
  297. #define YYFAIL        goto yyerrlab
  298. #define YYRECOVERING()  (!!yyerrstatus)
  299. #define YYBACKUP(token, value) \
  300. do                                \
  301.   if (yychar == YYEMPTY && yylen == 1)                \
  302.     { yychar = (token), yylval = (value);            \
  303.       yychar1 = YYTRANSLATE (yychar);                \
  304.       YYPOPSTACK;                        \
  305.       goto yybackup;                        \
  306.     }                                \
  307.   else                                \
  308.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  309. while (0)
  310.  
  311. #define YYTERROR    1
  312. #define YYERRCODE    256
  313.  
  314. #ifndef YYPURE
  315. #define YYLEX        yylex()
  316. #endif
  317.  
  318. #ifdef YYPURE
  319. #ifdef YYLSP_NEEDED
  320. #ifdef YYLEX_PARAM
  321. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  322. #else
  323. #define YYLEX        yylex(&yylval, &yylloc)
  324. #endif
  325. #else /* not YYLSP_NEEDED */
  326. #ifdef YYLEX_PARAM
  327. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  328. #else
  329. #define YYLEX        yylex(&yylval)
  330. #endif
  331. #endif /* not YYLSP_NEEDED */
  332. #endif
  333.  
  334. /* If nonreentrant, generate the variables here */
  335.  
  336. #ifndef YYPURE
  337.  
  338. int    yychar;            /*  the lookahead symbol        */
  339. YYSTYPE    yylval;            /*  the semantic value of the        */
  340.                 /*  lookahead symbol            */
  341.  
  342. #ifdef YYLSP_NEEDED
  343. YYLTYPE yylloc;            /*  location data for the lookahead    */
  344.                 /*  symbol                */
  345. #endif
  346.  
  347. int yynerrs;            /*  number of parse errors so far       */
  348. #endif  /* not YYPURE */
  349.  
  350. #if YYDEBUG != 0
  351. int yydebug;            /*  nonzero means print parse trace    */
  352. /* Since this is uninitialized, it does not stop multiple parsers
  353.    from coexisting.  */
  354. #endif
  355.  
  356. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  357.  
  358. #ifndef    YYINITDEPTH
  359. #define YYINITDEPTH 200
  360. #endif
  361.  
  362. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  363.     (effective only if the built-in stack extension method is used).  */
  364.  
  365. #if YYMAXDEPTH == 0
  366. #undef YYMAXDEPTH
  367. #endif
  368.  
  369. #ifndef YYMAXDEPTH
  370. #define YYMAXDEPTH 10000
  371. #endif
  372.  
  373. /* Prevent warning if -Wstrict-prototypes.  */
  374. #ifdef __GNUC__
  375. int yyparse (void);
  376. #endif
  377.  
  378. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  379. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  380. #else                /* not GNU C or C++ */
  381. #ifndef __cplusplus
  382.  
  383. /* This is the most reliable way to avoid incompatibilities
  384.    in available built-in functions on various systems.  */
  385. static void
  386. __yy_memcpy (to, from, count)
  387.      char *to;
  388.      char *from;
  389.      int count;
  390. {
  391.   register char *f = from;
  392.   register char *t = to;
  393.   register int i = count;
  394.  
  395.   while (i-- > 0)
  396.     *t++ = *f++;
  397. }
  398.  
  399. #else /* __cplusplus */
  400.  
  401. /* This is the most reliable way to avoid incompatibilities
  402.    in available built-in functions on various systems.  */
  403. static void
  404. __yy_memcpy (char *to, char *from, int count)
  405. {
  406.   register char *t = to;
  407.   register char *f = from;
  408.   register int i = count;
  409.  
  410.   while (i-- > 0)
  411.     *t++ = *f++;
  412. }
  413.  
  414. #endif
  415. #endif
  416.  
  417. #line 196 "/p/share/bison.simple"
  418.  
  419. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  420.    into yyparse.  The argument should have type void *.
  421.    It should actually point to an object.
  422.    Grammar actions can access the variable by casting it
  423.    to the proper pointer type.  */
  424.  
  425. #ifdef YYPARSE_PARAM
  426. #ifdef __cplusplus
  427. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  428. #define YYPARSE_PARAM_DECL
  429. #else /* not __cplusplus */
  430. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  431. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  432. #endif /* not __cplusplus */
  433. #else /* not YYPARSE_PARAM */
  434. #define YYPARSE_PARAM_ARG
  435. #define YYPARSE_PARAM_DECL
  436. #endif /* not YYPARSE_PARAM */
  437.  
  438. int
  439. yyparse(YYPARSE_PARAM_ARG)
  440.      YYPARSE_PARAM_DECL
  441. {
  442.   register int yystate;
  443.   register int yyn;
  444.   register short *yyssp;
  445.   register YYSTYPE *yyvsp;
  446.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  447.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  448.  
  449.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  450.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  451.  
  452.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  453.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  454.  
  455. #ifdef YYLSP_NEEDED
  456.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  457.   YYLTYPE *yyls = yylsa;
  458.   YYLTYPE *yylsp;
  459.  
  460. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  461. #else
  462. #define YYPOPSTACK   (yyvsp--, yyssp--)
  463. #endif
  464.  
  465.   int yystacksize = YYINITDEPTH;
  466.  
  467. #ifdef YYPURE
  468.   int yychar;
  469.   YYSTYPE yylval;
  470.   int yynerrs;
  471. #ifdef YYLSP_NEEDED
  472.   YYLTYPE yylloc;
  473. #endif
  474. #endif
  475.  
  476.   YYSTYPE yyval;        /*  the variable used to return        */
  477.                 /*  semantic values from the action    */
  478.                 /*  routines                */
  479.  
  480.   int yylen;
  481.  
  482. #if YYDEBUG != 0
  483.   if (yydebug)
  484.     fprintf(stderr, "Starting parse\n");
  485. #endif
  486.  
  487.   yystate = 0;
  488.   yyerrstatus = 0;
  489.   yynerrs = 0;
  490.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  491.  
  492.   /* Initialize stack pointers.
  493.      Waste one element of value and location stack
  494.      so that they stay on the same level as the state stack.
  495.      The wasted elements are never initialized.  */
  496.  
  497.   yyssp = yyss - 1;
  498.   yyvsp = yyvs;
  499. #ifdef YYLSP_NEEDED
  500.   yylsp = yyls;
  501. #endif
  502.  
  503. /* Push a new state, which is found in  yystate  .  */
  504. /* In all cases, when you get here, the value and location stacks
  505.    have just been pushed. so pushing a state here evens the stacks.  */
  506. yynewstate:
  507.  
  508.   *++yyssp = yystate;
  509.  
  510.   if (yyssp >= yyss + yystacksize - 1)
  511.     {
  512.       /* Give user a chance to reallocate the stack */
  513.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  514.       YYSTYPE *yyvs1 = yyvs;
  515.       short *yyss1 = yyss;
  516. #ifdef YYLSP_NEEDED
  517.       YYLTYPE *yyls1 = yyls;
  518. #endif
  519.  
  520.       /* Get the current used size of the three stacks, in elements.  */
  521.       int size = yyssp - yyss + 1;
  522.  
  523. #ifdef yyoverflow
  524.       /* Each stack pointer address is followed by the size of
  525.      the data in use in that stack, in bytes.  */
  526. #ifdef YYLSP_NEEDED
  527.       /* This used to be a conditional around just the two extra args,
  528.      but that might be undefined if yyoverflow is a macro.  */
  529.       yyoverflow("parser stack overflow",
  530.          &yyss1, size * sizeof (*yyssp),
  531.          &yyvs1, size * sizeof (*yyvsp),
  532.          &yyls1, size * sizeof (*yylsp),
  533.          &yystacksize);
  534. #else
  535.       yyoverflow("parser stack overflow",
  536.          &yyss1, size * sizeof (*yyssp),
  537.          &yyvs1, size * sizeof (*yyvsp),
  538.          &yystacksize);
  539. #endif
  540.  
  541.       yyss = yyss1; yyvs = yyvs1;
  542. #ifdef YYLSP_NEEDED
  543.       yyls = yyls1;
  544. #endif
  545. #else /* no yyoverflow */
  546.       /* Extend the stack our own way.  */
  547.       if (yystacksize >= YYMAXDEPTH)
  548.     {
  549.       yyerror("parser stack overflow");
  550.       return 2;
  551.     }
  552.       yystacksize *= 2;
  553.       if (yystacksize > YYMAXDEPTH)
  554.     yystacksize = YYMAXDEPTH;
  555.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  556.       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
  557.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  558.       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
  559. #ifdef YYLSP_NEEDED
  560.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  561.       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
  562. #endif
  563. #endif /* no yyoverflow */
  564.  
  565.       yyssp = yyss + size - 1;
  566.       yyvsp = yyvs + size - 1;
  567. #ifdef YYLSP_NEEDED
  568.       yylsp = yyls + size - 1;
  569. #endif
  570.  
  571. #if YYDEBUG != 0
  572.       if (yydebug)
  573.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  574. #endif
  575.  
  576.       if (yyssp >= yyss + yystacksize - 1)
  577.     YYABORT;
  578.     }
  579.  
  580. #if YYDEBUG != 0
  581.   if (yydebug)
  582.     fprintf(stderr, "Entering state %d\n", yystate);
  583. #endif
  584.  
  585.   goto yybackup;
  586.  yybackup:
  587.  
  588. /* Do appropriate processing given the current state.  */
  589. /* Read a lookahead token if we need one and don't already have one.  */
  590. /* yyresume: */
  591.  
  592.   /* First try to decide what to do without reference to lookahead token.  */
  593.  
  594.   yyn = yypact[yystate];
  595.   if (yyn == YYFLAG)
  596.     goto yydefault;
  597.  
  598.   /* Not known => get a lookahead token if don't already have one.  */
  599.  
  600.   /* yychar is either YYEMPTY or YYEOF
  601.      or a valid token in external form.  */
  602.  
  603.   if (yychar == YYEMPTY)
  604.     {
  605. #if YYDEBUG != 0
  606.       if (yydebug)
  607.     fprintf(stderr, "Reading a token: ");
  608. #endif
  609.       yychar = YYLEX;
  610.     }
  611.  
  612.   /* Convert token to internal form (in yychar1) for indexing tables with */
  613.  
  614.   if (yychar <= 0)        /* This means end of input. */
  615.     {
  616.       yychar1 = 0;
  617.       yychar = YYEOF;        /* Don't call YYLEX any more */
  618.  
  619. #if YYDEBUG != 0
  620.       if (yydebug)
  621.     fprintf(stderr, "Now at end of input.\n");
  622. #endif
  623.     }
  624.   else
  625.     {
  626.       yychar1 = YYTRANSLATE(yychar);
  627.  
  628. #if YYDEBUG != 0
  629.       if (yydebug)
  630.     {
  631.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  632.       /* Give the individual parser a way to print the precise meaning
  633.          of a token, for further debugging info.  */
  634. #ifdef YYPRINT
  635.       YYPRINT (stderr, yychar, yylval);
  636. #endif
  637.       fprintf (stderr, ")\n");
  638.     }
  639. #endif
  640.     }
  641.  
  642.   yyn += yychar1;
  643.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  644.     goto yydefault;
  645.  
  646.   yyn = yytable[yyn];
  647.  
  648.   /* yyn is what to do for this token type in this state.
  649.      Negative => reduce, -yyn is rule number.
  650.      Positive => shift, yyn is new state.
  651.        New state is final state => don't bother to shift,
  652.        just return success.
  653.      0, or most negative number => error.  */
  654.  
  655.   if (yyn < 0)
  656.     {
  657.       if (yyn == YYFLAG)
  658.     goto yyerrlab;
  659.       yyn = -yyn;
  660.       goto yyreduce;
  661.     }
  662.   else if (yyn == 0)
  663.     goto yyerrlab;
  664.  
  665.   if (yyn == YYFINAL)
  666.     YYACCEPT;
  667.  
  668.   /* Shift the lookahead token.  */
  669.  
  670. #if YYDEBUG != 0
  671.   if (yydebug)
  672.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  673. #endif
  674.  
  675.   /* Discard the token being shifted unless it is eof.  */
  676.   if (yychar != YYEOF)
  677.     yychar = YYEMPTY;
  678.  
  679.   *++yyvsp = yylval;
  680. #ifdef YYLSP_NEEDED
  681.   *++yylsp = yylloc;
  682. #endif
  683.  
  684.   /* count tokens shifted since error; after three, turn off error status.  */
  685.   if (yyerrstatus) yyerrstatus--;
  686.  
  687.   yystate = yyn;
  688.   goto yynewstate;
  689.  
  690. /* Do the default action for the current state.  */
  691. yydefault:
  692.  
  693.   yyn = yydefact[yystate];
  694.   if (yyn == 0)
  695.     goto yyerrlab;
  696.  
  697. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  698. yyreduce:
  699.   yylen = yyr2[yyn];
  700.   if (yylen > 0)
  701.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  702.  
  703. #if YYDEBUG != 0
  704.   if (yydebug)
  705.     {
  706.       int i;
  707.  
  708.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  709.            yyn, yyrline[yyn]);
  710.  
  711.       /* Print the symbols being reduced, and their result.  */
  712.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  713.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  714.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  715.     }
  716. #endif
  717.  
  718.  
  719.   switch (yyn) {
  720.  
  721. case 1:
  722. #line 131 "posixtm.y"
  723. {
  724.              if (yyvsp[-5] >= 1 && yyvsp[-5] <= 12)
  725.            t.tm_mon = yyvsp[-5] - 1;
  726.          else {
  727.            YYABORT;
  728.          }
  729.          if (yyvsp[-4] >= 1 && yyvsp[-4] <= 31)
  730.            t.tm_mday = yyvsp[-4];
  731.          else {
  732.            YYABORT;
  733.          }
  734.          if (yyvsp[-3] >= 0 && yyvsp[-3] <= 23)
  735.            t.tm_hour = yyvsp[-3];
  736.          else {
  737.            YYABORT;
  738.          }
  739.          if (yyvsp[-2] >= 0 && yyvsp[-2] <= 59)
  740.            t.tm_min = yyvsp[-2];
  741.          else {
  742.            YYABORT;
  743.          }
  744.            ;
  745.     break;}
  746. case 2:
  747. #line 154 "posixtm.y"
  748. {
  749.                    t.tm_year = yyvsp[0];
  750.            /* Deduce the century based on the year.
  751.               See POSIX.2 section 4.63.3.  */
  752.            if (yyvsp[0] <= 68)
  753.              t.tm_year += 100;
  754.          ;
  755.     break;}
  756. case 3:
  757. #line 161 "posixtm.y"
  758. {
  759.                             t.tm_year = yyvsp[-1] * 100 + yyvsp[0];
  760.                 if (t.tm_year < 1900) {
  761.                   YYABORT;
  762.                 } else
  763.                   t.tm_year -= 1900;
  764.               ;
  765.     break;}
  766. case 4:
  767. #line 168 "posixtm.y"
  768. {
  769.                     time_t now;
  770.             struct tm *tmp;
  771.  
  772.                     /* Use current year.  */
  773.                     time (&now);
  774.             tmp = localtime (&now);
  775.             t.tm_year = tmp->tm_year;
  776.           ;
  777.     break;}
  778. case 5:
  779. #line 179 "posixtm.y"
  780. {
  781.                         t.tm_sec = 0;
  782.               ;
  783.     break;}
  784. case 6:
  785. #line 182 "posixtm.y"
  786. {
  787.                       if (yyvsp[0] >= 0 && yyvsp[0] <= 61)
  788.                 t.tm_sec = yyvsp[0];
  789.               else {
  790.                 YYABORT;
  791.               }
  792.             ;
  793.     break;}
  794. case 7:
  795. #line 191 "posixtm.y"
  796. {
  797.                           yyval = yyvsp[-1] * 10 + yyvsp[0];
  798.             ;
  799.     break;}
  800. }
  801.    /* the action file gets copied in in place of this dollarsign */
  802. #line 498 "/p/share/bison.simple"
  803.  
  804.   yyvsp -= yylen;
  805.   yyssp -= yylen;
  806. #ifdef YYLSP_NEEDED
  807.   yylsp -= yylen;
  808. #endif
  809.  
  810. #if YYDEBUG != 0
  811.   if (yydebug)
  812.     {
  813.       short *ssp1 = yyss - 1;
  814.       fprintf (stderr, "state stack now");
  815.       while (ssp1 != yyssp)
  816.     fprintf (stderr, " %d", *++ssp1);
  817.       fprintf (stderr, "\n");
  818.     }
  819. #endif
  820.  
  821.   *++yyvsp = yyval;
  822.  
  823. #ifdef YYLSP_NEEDED
  824.   yylsp++;
  825.   if (yylen == 0)
  826.     {
  827.       yylsp->first_line = yylloc.first_line;
  828.       yylsp->first_column = yylloc.first_column;
  829.       yylsp->last_line = (yylsp-1)->last_line;
  830.       yylsp->last_column = (yylsp-1)->last_column;
  831.       yylsp->text = 0;
  832.     }
  833.   else
  834.     {
  835.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  836.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  837.     }
  838. #endif
  839.  
  840.   /* Now "shift" the result of the reduction.
  841.      Determine what state that goes to,
  842.      based on the state we popped back to
  843.      and the rule number reduced by.  */
  844.  
  845.   yyn = yyr1[yyn];
  846.  
  847.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  848.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  849.     yystate = yytable[yystate];
  850.   else
  851.     yystate = yydefgoto[yyn - YYNTBASE];
  852.  
  853.   goto yynewstate;
  854.  
  855. yyerrlab:   /* here on detecting error */
  856.  
  857.   if (! yyerrstatus)
  858.     /* If not already recovering from an error, report this error.  */
  859.     {
  860.       ++yynerrs;
  861.  
  862. #ifdef YYERROR_VERBOSE
  863.       yyn = yypact[yystate];
  864.  
  865.       if (yyn > YYFLAG && yyn < YYLAST)
  866.     {
  867.       int size = 0;
  868.       char *msg;
  869.       int x, count;
  870.  
  871.       count = 0;
  872.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  873.       for (x = (yyn < 0 ? -yyn : 0);
  874.            x < (sizeof(yytname) / sizeof(char *)); x++)
  875.         if (yycheck[x + yyn] == x)
  876.           size += strlen(yytname[x]) + 15, count++;
  877.       msg = (char *) malloc(size + 15);
  878.       if (msg != 0)
  879.         {
  880.           strcpy(msg, "parse error");
  881.  
  882.           if (count < 5)
  883.         {
  884.           count = 0;
  885.           for (x = (yyn < 0 ? -yyn : 0);
  886.                x < (sizeof(yytname) / sizeof(char *)); x++)
  887.             if (yycheck[x + yyn] == x)
  888.               {
  889.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  890.             strcat(msg, yytname[x]);
  891.             strcat(msg, "'");
  892.             count++;
  893.               }
  894.         }
  895.           yyerror(msg);
  896.           free(msg);
  897.         }
  898.       else
  899.         yyerror ("parse error; also virtual memory exceeded");
  900.     }
  901.       else
  902. #endif /* YYERROR_VERBOSE */
  903.     yyerror("parse error");
  904.     }
  905.  
  906.   goto yyerrlab1;
  907. yyerrlab1:   /* here on error raised explicitly by an action */
  908.  
  909.   if (yyerrstatus == 3)
  910.     {
  911.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  912.  
  913.       /* return failure if at end of input */
  914.       if (yychar == YYEOF)
  915.     YYABORT;
  916.  
  917. #if YYDEBUG != 0
  918.       if (yydebug)
  919.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  920. #endif
  921.  
  922.       yychar = YYEMPTY;
  923.     }
  924.  
  925.   /* Else will try to reuse lookahead token
  926.      after shifting the error token.  */
  927.  
  928.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  929.  
  930.   goto yyerrhandle;
  931.  
  932. yyerrdefault:  /* current state does not do anything special for the error token. */
  933.  
  934. #if 0
  935.   /* This is wrong; only states that explicitly want error tokens
  936.      should shift them.  */
  937.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  938.   if (yyn) goto yydefault;
  939. #endif
  940.  
  941. yyerrpop:   /* pop the current state because it cannot handle the error token */
  942.  
  943.   if (yyssp == yyss) YYABORT;
  944.   yyvsp--;
  945.   yystate = *--yyssp;
  946. #ifdef YYLSP_NEEDED
  947.   yylsp--;
  948. #endif
  949.  
  950. #if YYDEBUG != 0
  951.   if (yydebug)
  952.     {
  953.       short *ssp1 = yyss - 1;
  954.       fprintf (stderr, "Error: state stack now");
  955.       while (ssp1 != yyssp)
  956.     fprintf (stderr, " %d", *++ssp1);
  957.       fprintf (stderr, "\n");
  958.     }
  959. #endif
  960.  
  961. yyerrhandle:
  962.  
  963.   yyn = yypact[yystate];
  964.   if (yyn == YYFLAG)
  965.     goto yyerrdefault;
  966.  
  967.   yyn += YYTERROR;
  968.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  969.     goto yyerrdefault;
  970.  
  971.   yyn = yytable[yyn];
  972.   if (yyn < 0)
  973.     {
  974.       if (yyn == YYFLAG)
  975.     goto yyerrpop;
  976.       yyn = -yyn;
  977.       goto yyreduce;
  978.     }
  979.   else if (yyn == 0)
  980.     goto yyerrpop;
  981.  
  982.   if (yyn == YYFINAL)
  983.     YYACCEPT;
  984.  
  985. #if YYDEBUG != 0
  986.   if (yydebug)
  987.     fprintf(stderr, "Shifting error token, ");
  988. #endif
  989.  
  990.   *++yyvsp = yylval;
  991. #ifdef YYLSP_NEEDED
  992.   *++yylsp = yylloc;
  993. #endif
  994.  
  995.   yystate = yyn;
  996.   goto yynewstate;
  997. }
  998. #line 195 "posixtm.y"
  999.  
  1000. static int
  1001. yylex ()
  1002. {
  1003.   char ch = *curpos++;
  1004.  
  1005.   if (ch >= '0' && ch <= '9')
  1006.     {
  1007.       yylval = ch - '0';
  1008.       return DIGIT;
  1009.     }
  1010.   else if (ch == '.' || ch == 0)
  1011.     return ch;
  1012.   else
  1013.     return '?';            /* Cause an error.  */
  1014. }
  1015.  
  1016. static int
  1017. yyerror ()
  1018. {
  1019.   return 0;
  1020. }
  1021.  
  1022. /* Parse a POSIX-style date and return it, or (time_t)-1 for an error.  */
  1023.  
  1024. time_t
  1025. posixtime (s)
  1026.      char *s;
  1027. {
  1028.   curpos = s;
  1029.   /* Let mktime decide whether it is daylight savings time.  */
  1030.   t.tm_isdst = -1;
  1031.   if (yyparse ())
  1032.     return (time_t)-1;
  1033.   else
  1034.     return mktime (&t);
  1035. }
  1036.  
  1037. /* Parse a POSIX-style date and return it, or NULL for an error.  */
  1038.  
  1039. struct tm *
  1040. posixtm (s)
  1041.      char *s;
  1042. {
  1043.   if (posixtime (s) == -1)
  1044.     return NULL;
  1045.   return &t;
  1046. }
  1047.